import $http from "./request.js";
// 网络监听
const NetWork = {
	// 网络状态
	isConnect:false,
	// 监听网络状态
	On(){
		// 获取当前网络状态
		uni.getNetworkType({
			success: (res) => {
				if(res.networkType!=='none'){ 
					this.isConnect=true; 
					return;
					}
				uni.showModal({
					title: '',
					content: $t('common.api.neterror'),
					showCancel: false,
					confirmText: $t('common.api.sure'),
					success: function (res) {
						
					}
				});
			}
		})
		// 监听网络状态变化
		uni.onNetworkStatusChange((res)=>{
			this.isConnect = res.isConnected;
			if(!res.isConnected){
				uni.showModal({
					title: '',
					content:$t('common.api.netend'),
					showCancel: false,
					confirmText: $t('common.api.sure'),
					success: function (res) {
						
					}
				});
			}
		})
	}
}

import config from "./config.js"
export default {
	NetWork,
}